package com.cn.dim.utils;

import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.GregorianCalendar;
import java.util.UUID;


public final class StringUtil {
    /** 随机数。 */
    private static int serial = 0;

    /** 随机数最大值。 */
    private static final int MAX_SERIAL = 999;

    /** 随机数长度。 */
    private static final int SEQUENCE_LENTH = 12;

    public static synchronized String makeUUID() {
    	
        StringBuffer ret = new StringBuffer();
        SimpleDateFormat dfDate = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        dfDate.setLenient(false);
        ret.append(dfDate.format((new GregorianCalendar()).getTime()));     
        DecimalFormat dfNum = new DecimalFormat("000");
        ret.append(dfNum.format(serial++));
        if (serial > MAX_SERIAL) {
            serial = 0;
        }
        UUID uuid = UUID.randomUUID();
        ret.append(uuid.toString().replace("-", "").subSequence(0, SEQUENCE_LENTH));

        return ret.toString();
    }

    public static synchronized String selfMakeUUID() {
        String s = UUID.randomUUID().toString();
        String value = s.substring(0, 8) + s.substring(9, 13) + s.substring(14, 18) + s.substring(19, 23) + s.substring(24);
        return value;
    }

    public static boolean isEmptyOrNull(String str) {
        boolean isEmptyOrNull = true;
        if (str != null && str.length() != 0) {
            isEmptyOrNull = false;
        }
        return isEmptyOrNull;
    }
    
    public static void main(String[] args) {
	}
    
    
}
